package com.example.demo.leetcode.classics150;

/**
 * ******************************************************
 *
 * @author liugh9
 * @version 1.0
 * @classname _26判断子序列
 * @description
 * @date 2023/07/16 8:48
 * <p>
 * ******************************************************
 */
public class _26判断子序列 {
    public boolean isSubsequence(String s, String t) {
        int sIndex = 0;
        int sLength = s.length();
        int tIndex = 0;
        int tLength = t.length();
        if (sLength > tLength) {
            return false;
        }

        while (sIndex < sLength && tIndex < tLength) {
            char curr = s.charAt(sIndex);
            if (curr == t.charAt(tIndex)) {
                sIndex++;
                tIndex++;
            } else {
                tIndex++;
            }
        }
        return sIndex == sLength;
    }
}
